<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span class="hs-cpp">
#if __GLASGOW_HASKELL__ &gt;= 711
</span><span class="hs-pragma">{-# LANGUAGE PatternSynonyms #-}</span><span class="hs-cpp">
#endif
</span><span class="hs-cpp">
#ifndef MIN_VERSION_binary
</span><span class="hs-cpp">#define MIN_VERSION_binary(x, y, z) 0
</span><span class="hs-cpp">#endif
</span><span>
</span><span id="line-10"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Distribution.Compat.Binary</span><span>
</span><span id="line-11"></span><span>       </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="Distribution.Compat.Binary.html#decodeOrFailIO"><span class="hs-identifier">decodeOrFailIO</span></a></span><span>
</span><span id="line-12"></span><span>       </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Distribution.Compat.Binary.html#decodeFileOrFail%27"><span class="hs-identifier">decodeFileOrFail'</span></a></span><span class="hs-cpp">
#if __GLASGOW_HASKELL__ &gt;= 708 || MIN_VERSION_binary(0,7,0)
</span><span>       </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">module</span><span> </span><span class="annot"><a href="../../binary/src/Data.Binary.html#"><span class="hs-identifier">Data.Binary</span></a></span><span class="hs-cpp">
#else
</span><span>       </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">Binary</span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span>
</span><span id="line-17"></span><span>       </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">decode</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">encode</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">encodeFile</span><span class="hs-cpp">
#endif
</span><span>       </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-20"></span><span>
</span><span id="line-21"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Exception.html#"><span class="hs-identifier">Control.Exception</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Exception.html#ErrorCall"><span class="hs-identifier">ErrorCall</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#catch"><span class="hs-identifier">catch</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#evaluate"><span class="hs-identifier">evaluate</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-22"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Lazy.html#"><span class="hs-identifier">Data.ByteString.Lazy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Lazy.Internal.html#ByteString"><span class="hs-identifier">ByteString</span></a></span><span class="hs-special">)</span><span class="hs-cpp">

#if __GLASGOW_HASKELL__ &gt;= 708 || MIN_VERSION_binary(0,7,0)
</span><span>
</span><span id="line-26"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../binary/src/Data.Binary.html#"><span class="hs-identifier">Data.Binary</span></a></span><span>
</span><span id="line-27"></span><span>
</span><span id="line-28"></span><span class="hs-comment">-- | Lazily reconstruct a value previously written to a file.</span><span>
</span><span id="line-29"></span><span id="local-6989586621679612232"><span class="annot"><a href="Distribution.Compat.Binary.html#decodeFileOrFail%27"><span class="hs-identifier hs-type">decodeFileOrFail'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../binary/src/Data.Binary.Class.html#Binary"><span class="hs-identifier hs-type">Binary</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679612232"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Either"><span class="hs-identifier hs-type">Either</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679612232"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-30"></span><span id="decodeFileOrFail%27"><span class="annot"><span class="annottext">decodeFileOrFail' :: forall a. Binary a =&gt; FilePath -&gt; IO (Either FilePath a)
</span><a href="Distribution.Compat.Binary.html#decodeFileOrFail%27"><span class="hs-identifier hs-var hs-var">decodeFileOrFail'</span></a></span></span><span> </span><span id="local-6989586621679612187"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679612187"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((ByteOffset, FilePath) -&gt; Either FilePath a)
-&gt; (a -&gt; Either FilePath a)
-&gt; Either (ByteOffset, FilePath) a
-&gt; Either FilePath a
forall a c b. (a -&gt; c) -&gt; (b -&gt; c) -&gt; Either a b -&gt; c
</span><a href="../../base/src/Data.Either.html#either"><span class="hs-identifier hs-var">either</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath -&gt; Either FilePath a
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; Either FilePath a)
-&gt; ((ByteOffset, FilePath) -&gt; FilePath)
-&gt; (ByteOffset, FilePath)
-&gt; Either FilePath a
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(ByteOffset, FilePath) -&gt; FilePath
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">a -&gt; Either FilePath a
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="annot"><span class="annottext">(Either (ByteOffset, FilePath) a -&gt; Either FilePath a)
-&gt; IO (Either (ByteOffset, FilePath) a) -&gt; IO (Either FilePath a)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-operator hs-var">`fmap`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO (Either (ByteOffset, FilePath) a)
forall a.
Binary a =&gt;
FilePath -&gt; IO (Either (ByteOffset, FilePath) a)
</span><a href="../../binary/src/Data.Binary.html#decodeFileOrFail"><span class="hs-identifier hs-var">decodeFileOrFail</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679612187"><span class="hs-identifier hs-var">f</span></a></span><span class="hs-cpp">

#else
</span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Data.Binary.Get</span><span>
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Data.Binary.Put</span><span>
</span><span id="line-36"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="hs-identifier">Data.ByteString.Lazy</span><span> </span><span class="hs-keyword">as</span><span> </span><span class="hs-identifier">BSL</span><span>
</span><span id="line-37"></span><span>
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Distribution.Compat.Binary.Class</span><span>
</span><span id="line-39"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Distribution.Compat.Binary.Generic</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-40"></span><span>
</span><span id="line-41"></span><span class="hs-comment">-- | Decode a value from a lazy ByteString, reconstructing the</span><span>
</span><span id="line-42"></span><span class="hs-comment">-- original structure.</span><span>
</span><span id="line-43"></span><span class="hs-comment">--</span><span>
</span><span id="line-44"></span><span class="hs-identifier">decode</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Binary</span><span> </span><span class="hs-identifier">a</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-identifier">ByteString</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">a</span><span>
</span><span id="line-45"></span><span class="hs-identifier">decode</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">runGet</span><span> </span><span class="hs-identifier">get</span><span>
</span><span id="line-46"></span><span>
</span><span id="line-47"></span><span class="hs-comment">-- | Encode a value using binary serialisation to a lazy ByteString.</span><span>
</span><span id="line-48"></span><span class="hs-comment">--</span><span>
</span><span id="line-49"></span><span class="hs-identifier">encode</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Binary</span><span> </span><span class="hs-identifier">a</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-identifier">a</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">ByteString</span><span>
</span><span id="line-50"></span><span class="hs-identifier">encode</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">runPut</span><span> </span><span class="hs-operator">.</span><span> </span><span class="hs-identifier">put</span><span>
</span><span id="line-51"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="hs-pragma">encode</span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-52"></span><span>
</span><span id="line-53"></span><span class="hs-comment">-- | Lazily reconstruct a value previously written to a file.</span><span>
</span><span id="line-54"></span><span class="hs-identifier">decodeFileOrFail'</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Binary</span><span> </span><span class="hs-identifier">a</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-identifier">FilePath</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Either</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-identifier">a</span><span class="hs-special">)</span><span>
</span><span id="line-55"></span><span class="hs-identifier">decodeFileOrFail'</span><span> </span><span class="hs-identifier">f</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">decodeOrFailIO</span><span> </span><span class="hs-operator">=&lt;&lt;</span><span> </span><span class="hs-identifier">BSL.readFile</span><span> </span><span class="hs-identifier">f</span><span>
</span><span id="line-56"></span><span>
</span><span id="line-57"></span><span class="hs-comment">-- | Lazily serialise a value to a file</span><span>
</span><span id="line-58"></span><span class="hs-identifier">encodeFile</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Binary</span><span> </span><span class="hs-identifier">a</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-identifier">FilePath</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">a</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-59"></span><span class="hs-identifier">encodeFile</span><span> </span><span class="hs-identifier">f</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">BSL.writeFile</span><span> </span><span class="hs-identifier">f</span><span> </span><span class="hs-operator">.</span><span> </span><span class="hs-identifier">encode</span><span class="hs-cpp">

#endif
</span><span>
</span><span id="line-63"></span><span id="local-6989586621679612213"><span class="annot"><a href="Distribution.Compat.Binary.html#decodeOrFailIO"><span class="hs-identifier hs-type">decodeOrFailIO</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../binary/src/Data.Binary.Class.html#Binary"><span class="hs-identifier hs-type">Binary</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679612213"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Lazy.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Either"><span class="hs-identifier hs-type">Either</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679612213"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-64"></span><span id="decodeOrFailIO"><span class="annot"><span class="annottext">decodeOrFailIO :: forall a. Binary a =&gt; ByteString -&gt; IO (Either FilePath a)
</span><a href="Distribution.Compat.Binary.html#decodeOrFailIO"><span class="hs-identifier hs-var hs-var">decodeOrFailIO</span></a></span></span><span> </span><span id="local-6989586621679612175"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679612175"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-65"></span><span>    </span><span class="annot"><span class="annottext">IO (Either FilePath a)
-&gt; (ErrorCall -&gt; IO (Either FilePath a)) -&gt; IO (Either FilePath a)
forall e a. Exception e =&gt; IO a -&gt; (e -&gt; IO a) -&gt; IO a
</span><a href="../../base/src/GHC.IO.html#catch"><span class="hs-identifier hs-var">catch</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; IO a
forall a. a -&gt; IO a
</span><a href="../../base/src/GHC.IO.html#evaluate"><span class="hs-identifier hs-var">evaluate</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ByteString -&gt; a
forall a. Binary a =&gt; ByteString -&gt; a
</span><a href="../../binary/src/Data.Binary.html#decode"><span class="hs-identifier hs-var">decode</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679612175"><span class="hs-identifier hs-var">bs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IO a -&gt; (a -&gt; IO (Either FilePath a)) -&gt; IO (Either FilePath a)
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Either FilePath a -&gt; IO (Either FilePath a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Either FilePath a -&gt; IO (Either FilePath a))
-&gt; (a -&gt; Either FilePath a) -&gt; a -&gt; IO (Either FilePath a)
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; Either FilePath a
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">ErrorCall -&gt; IO (Either FilePath a)
forall {m :: * -&gt; *} {b}.
Monad m =&gt;
ErrorCall -&gt; m (Either FilePath b)
</span><a href="#local-6989586621679612173"><span class="hs-identifier hs-var">handler</span></a></span><span>
</span><span id="line-66"></span><span>  </span><span class="hs-keyword">where</span><span class="hs-cpp">
#if MIN_VERSION_base(4,9,0)
</span><span>    </span><span id="local-6989586621679612173"><span class="annot"><span class="annottext">handler :: ErrorCall -&gt; m (Either FilePath b)
</span><a href="#local-6989586621679612173"><span class="hs-identifier hs-var hs-var">handler</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Exception.html#ErrorCallWithLocation"><span class="hs-identifier hs-type">ErrorCallWithLocation</span></a></span><span> </span><span id="local-6989586621679612169"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679612169"><span class="hs-identifier hs-var">str</span></a></span></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Either FilePath b -&gt; m (Either FilePath b)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Either FilePath b -&gt; m (Either FilePath b))
-&gt; Either FilePath b -&gt; m (Either FilePath b)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; Either FilePath b
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679612169"><span class="hs-identifier hs-var">str</span></a></span><span class="hs-cpp">
#else
</span><span>    </span><span class="hs-identifier">handler</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">ErrorCall</span><span> </span><span class="hs-identifier">str</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">return</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">Left</span><span> </span><span class="hs-identifier">str</span><span class="hs-cpp">
#endif
</span></pre></body></html>